package com.oceansoft.mobile.econsole.modules.sys.service;

import com.oceansoft.mobile.econsole.cache.redis.CacheBaseService;
import com.oceansoft.mobile.econsole.common.util.MD5Util;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.json.JSONObject;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

/**
 * Created by Administrator on 2016/1/29.
 */
public class WtUserService extends CacheBaseService {

    private static final String asmxUrl ="http://gafw.jl.gov.cn:91/SingleLogin.asmx";
//    private static final String asmxUrl ="http://172.17.118.24:26017/SingleLogin.asmx";
    private static final String nameSpaceUri = "http://tempuri.org/";
    private static WtUserService instance;

    public static synchronized WtUserService getInstance(){
        if(instance==null){
            instance = new WtUserService();
        }
        return instance;
    }

    /**
     * 获取网厅用户信息
     */
    public String getUserProfile(String token){

//        String asmxUrl = configInfo.getJlgaLogin();

        try {
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(asmxUrl);
            // 设置operation 名称，
            call.setOperationName(new QName(nameSpaceUri, "GetUserProfile"));
            // 设置参数
            call.addParameter(new QName(nameSpaceUri, "token"), XMLType.XSD_STRING, ParameterMode.IN);
            call.setReturnType(XMLType.XSD_STRING);
            call.setUseSOAPAction(true);
            call.setSOAPActionURI(nameSpaceUri+"GetUserProfile");

            Object[] params = new Object[1];
            params[0] = token;
            String result = (String) call.invoke(params);

            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
